import http from './../../../base/api/public'
import querystring from 'querystring'
import template from "vue-resource/src/url/template";

let sysConfig = require('@/../config/sysConfig')
let apiUrl = sysConfig.sfsApiUrlPre;

//分页查询页面接口(带查询条件)
export const page_list = (page, size, params) => {
  //将json数据params拼接为k-v对
  let stringify = querystring.stringify(params);
  //转发请求url
  return http.requestQuickGet(apiUrl + '/cms/page/list/' + page + '/' + size + '?' + stringify)
};

//新增页面接口
export const page_add = params => {
  return http.requestPost(apiUrl + '/cms/page/add', params)
};

//根据id获取页面数据接口
export const page_get = id => {
  return http.requestQuickGet(apiUrl + '/cms/page/get/' + id)
};

//修改页面提交接口
export const page_edit = (id, params) => {
  return http.requestPut(apiUrl + '/cms/page/edit/' + id, params)
};

//删除页面接口
export const page_delete = id => {
  return http.requestDelete(apiUrl + '/cms/page/delete/' + id)
};

//站点列表查询接口
export const site_list = () => {
  return http.requestQuickGet(apiUrl + '/cms/site/list')
};

//页面发布接口
export const post_page = id => {
  return http.requestPost(apiUrl + '/cms/page/postPage/' + id)
};

//********************************模板管理相关*********************************

//模板列表查询接口
export const template_getList = () => {
  return http.requestQuickGet(apiUrl + '/cms/template/getList')
};

//模板列表查询接口
export const template_list = (page, size, templateName) => {
  return http.requestQuickGet(apiUrl + '/cms/template/list/' + page + '/' + size + '/?templateName=' + templateName)
};

//新增模板接口
export const template_add = params => {
  return http.requestPost(apiUrl + '/cms/template/add', params)
};

//模板删除接口
export const template_delete = templateId => {
  return http.requestDelete(apiUrl + '/cms/template/delete/' + templateId);
};

//获取模板信息接口
export const template_get = templateId => {
  return http.requestGet(apiUrl + '/cms/template/get/' + templateId);
};

//模板编辑接口
export const template_edit = (templateId, params) => {
  return http.requestPut(apiUrl + '/cms/template/edit/' + templateId, params);
};


